package service.impl;

import dao.UserDao;
import dao.impl.UserDaoImpl;
import entry.User;
import exception.AppException;
import service.UserService;

public class UserServiceImpl implements UserService {
    UserDao userDao=new UserDaoImpl();
    /**
     * 登录
     *
     * @param user 有值的属性只有账号和密码
     * @return User 查询到的用户信息，如果没查到返回null
     * @throws AppException 登录失败抛出这个异常
     * @author 闫东杰
     */
    @Override
    public User login(User user) throws AppException {
        User result = userDao.selectUser(user);
        if(result == null){
            throw new AppException("USER001", "用户名或密码错误！");
        }
        return result;
    }
}
